package com.wfy.orchestra.thread

import android.os.Process
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

/**
 * @author : wangfengyuan
 * e-mail  : 446950883@qq.com
 * time    : 2025/3/19
 * desc    :
 * version : 1.0
 */
class CustomThreadFactory(private val prefix: String) : ThreadFactory {
    private val counter = AtomicInteger(0)
    override fun newThread(r: Runnable): Thread {
        return Thread(r, "$prefix-${counter.getAndIncrement()}").apply {
            priority = Process.THREAD_PRIORITY_BACKGROUND
        }
    }
}